﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Cms.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cms.Tests.Unit.Domain
{

    [TestClass]
    public class PluginTemplateTests
    {

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestGetAndSetCode()
        {
            PluginTemplate template = new PluginTemplate();
            Assert.AreEqual("", template.GetCode());
            Administrator admin = new Administrator();
            template.SetCode("some code", admin);
            Assert.AreEqual("some code", template.GetCode());
            Assert.AreEqual(1, template.SourceCode.Versions.Count);
        }


        [TestMethod]
        public void TestGetLiteral()
        {
            PluginTemplate template = new PluginTemplate();
            PluginTemplateLiteral literal = new PluginTemplateLiteral
                                            {
                                                ControlID = "lit1",
                                                ID = 1,
                                                Template = template
                                            };
            template.Literals.Add(literal);
            literal = new PluginTemplateLiteral
                        {
                            ControlID = "lit2",
                            ID = 2,
                            Template = template
                        };
            template.Literals.Add(literal);
            Assert.AreEqual("lit1", template.GetLiteral(1).ControlID);
            Assert.AreEqual("lit1", template.GetLiteral("lit1").ControlID);
        }

    }

}
